import 'dart:io';

import '../index.dart';

class PlatformUtil{

  PlatformUtil._();

  /// 是否为鸿蒙平台
  static bool isOhos = Platform.operatingSystem == 'ohos';

  /// 是否为安卓平台
  static bool isAndroid = GetPlatform.isAndroid;

  /// 是否为苹果平台
  static bool isIOS = GetPlatform.isIOS;

  /// 是否为macOS平台
  static bool isMacOS = GetPlatform.isMacOS;

  /// 是否为Windows平台
  static bool isWindows = GetPlatform.isWindows;

  /// 是否为Linux平台
  static bool isLinux = GetPlatform.isLinux;

  /// 是否为Fuchsia平台
  static bool isFuchsia = GetPlatform.isFuchsia;

  /// 是否为Web平台
  static bool isWeb = GetPlatform.isWeb;

  /// 是否为鸿蒙PC
  static bool get isOhosPC {
    bool isPC =  false;
    getDeviceInfo()
    .then((onValue){
      if (isOhos){
        isPC = (onValue as OhosDeviceInfo).deviceType == '2in1';
      }
    });
   return  isOhos && isPC;
  }

  /// 是否为移动平台
  static bool get isMobile => (isIOS || isAndroid || (isOhos && !isOhosPC)) && !isWeb;

  /// 是否为桌面平台
  static bool get isDesktop => (isMacOS || isWindows || isLinux || isOhosPC) && !isWeb;

  /// 是否为桌面UI
  static bool get isDesktopUI => isDesktop ||  isWeb;

}